package com.mxm.java;

public class ClassLoaderTest {
    public static void main(String[] args) {
        //获取系统类加载器
        ClassLoader systemClassLoader=ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);//sun.misc.Launcher$AppClassLoader@18b4aac2
        //获取其上层：扩展类加载器
        ClassLoader extClassloader=systemClassLoader.getParent();
        System.out.println(extClassloader);//   sun.misc.Launcher$ExtClassLoader@1540e19d


        //获取其上层
        ClassLoader bootstrapClassLoader=extClassloader.getParent();
        System.out.println(bootstrapClassLoader);//null


        //对于用户自定义类来说:使用系统类加载器加载
        ClassLoader classLoader=ClassLoaderTest.class.getClassLoader();
        System.out.println(classLoader);//sun.misc.Launcher$AppClassLoader@18b4aac2

        //string类使用引导类加载器进行加载--java的核心类库都是使用引导类加载器加载的
        ClassLoader classLoader1=String.class.getClassLoader();
        System.out.println(classLoader1);//null


    }
}
